package org.meb.speedway.web;

import java.util.ArrayList;
import java.util.List;

import lombok.Getter;

@Getter
public class LogItem {

	private String master;
	private List<String> details;
	private String masterStyleClass = "log-m";
	private String detailStyleClass = "log-d";

	public LogItem(String log, String delim, LogItemStyleClassResolver resolver) {
		String[] tokens = log.split(delim);
		master = tokens[0];
		if (tokens.length > 1) {
			details = new ArrayList<String>();
			for (int i = 0; i < tokens.length; i++) {
				details.add(tokens[i]);
			}
		}

		if (resolver.isError(master)) {
			masterStyleClass += " log-error";
			detailStyleClass += " log-error";
		}
	}
}
